仿真器VCS solver 对包含 function 约束的求解

您所在的位置:网站首页 verilog constraint 仿真器VCS solver 对包含 function 约束的求解

仿真器VCS solver 对包含 function 约束的求解

2023-12-17 12:12| 来源: 网络整理| 查看: 265

对于约束条件中包含function的解约束过程, function中的参数会被优先解开,function会被当作state value 而不是rand value 优先返回,这时候会发生解冲突,常见的vcs报错如下:

Error-[CNST-ICE] Constraint infeasible constraints error

Error-[CNST-CIF] Constraints inconsistency failure 

 举例:

 

make vcs 报error

按照常规理解,r1,r2,r3同时随机求解,满足约束条件即可,但是slover会对getSum中的r1,r2先求解,得到 r1,r2的值。 getSum返回值为 8‘hda, 不能同时满足约束条件,报错。

 

 再来看看irun仿真器的求解结果如何:

make irun 也不能保证每次求解结果符合要求,报warning

 

对于包含function 约束的求解,首先求解出function的值,并没有错误,这个也是符合 IEEE SystemVerilog Std 1800-2012 规范的。

可以使用  +ntb_func_eval_in_solver=1 选项规避错误的出现。这是一个 用户限制使用 (LCA) 的功能。

Limited Customer Availability features are features available with the select functionality. These features will be ready for a general release, based on customer feedback and meeting the required feature completion criteria. LCA features do not need any additional license keys.

仿真结果:完美求解出想要的结果。

如果不使用上述方法,也有两种 workaroud 的方法:

第一种:对fuction在约束中展开

第二种:加入per_randomize,把r3当作state value优先求解

 

这两种方法vcs, irun都可以求解出正确结果。

 

补充一些vcs和约束相关的仿真选项:

 

+ntb_solver_mode=1|2

1:  在第一次对每个类调用randomize()期间,求解器在分析约束方面花费了更多的预处理时间。对这个类的后续调用randomize()非常快。

2:  求解器只做最少的预处理,并分析对randomize()的每次调用中的约束。默认是2。

所以使用VCS时,如果对某一个class多次randomize, 适用 +ntb_solver_mode=1

 

+ntb_solver_debug=trace_all   trace所有randomize时solver的解约束过程

如果randomize次数太多,constraint太复杂,会打印太多信息。可以通过加上+ntb_solver_debug=serial 打印出每次randomize的编号,然后通过+ntb_solver_debug=trace_all+serial   +ntb_solver_debug_filter=编号 单独trace某一次的randomize过程

vcs 的solver会对每次randomize的rand value分成各个partition,可以指定查看某一次randomize某一个partition的解约束过程 +ntb_solver_debug_filter=5.3  5: 第五次randomize  3:第三个partition

+ntb_solver_debug=profile :对解约束的性能分析

+ntb_solver_debug=extract :可以将某一个约束提取出来,单独复现。如果是vcs自己报错的解约束冲突,则会自动将其放在 simv.cst/ 下面

 

Summary for the +ntb_solver_debug Option

The runtime option +ntb_solver_debug provides you with many constraint debug features to debug constraints in batch mode.

+ntb_solver_debug=serial

The serial number assignment to the randomizations in a simulation provides a method to identify the randomize() calls to be debugged next. Once identified, you can use this runtime option with appropriate arguments to report the trace and extract test cases. The constraint profiler also uses the same identification method to provide feedback, such as which specific randomize() calls to optimize for best performance improvements.

+ntb_solver_debug=trace

This enables solver trace reporting for the specified randomize() calls. This helps you to understand how VCS solves the random variables for given randomize calls. The +ntb_solver_debug_filter option is required to specify a list of randomize() calls for which to enable the solver trace.

+ntb_solver_debug=profile

This enables constraint profiling for the simulation at runtime. The profile report provides important information to you, such as which randomize calls should be targeted for improving constraint performance to bring down the total simulation runtime or memory.

+ntb_solver_debug=extract

This enables test case extraction for the specified randomize calls. This creates standalone test cases for you to compile and run outside the original design. This should help in quicker turnaround time to experiment possible fixes as it is faster to compile and run a smaller test case. The +ntb_solver_debug_filter option is required to specify a list of randomize calls for which to enable test case extraction.

+ntb_solver_debug=verbose

The +ntb_solver_debug=verbose option provides you more detailed information in the solver output. This information includes the file name and the line number for all the individual constraint conditions inside the constraint block from the solver output.

The sample solver output is as follows:

Solver failed when solving following set of constraints rand bit[7:0] r1; // rand_mode = ON constraint cons1 // (from this) (constraint_mode = ON) (test.v:4) { (r1 == 8'h1); // (test.v:5) (r1 == 8'h2); // (test.v:6) }

 

+ntb_enable_solver_trace=0|1|2

0: Disables tracing.

1:Enables tracing. This is the default.

2:Enables tracing with more verbose messagesj

+ntb_enable_solver_trace_on_failure[=0|1|2]   仅在发生failure时trace 2为default

 

./simv +ntb_random_seed=value  设置随机种子

./simv +ntb_random_seed_automatic  

 



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3